module.exports = {
	data() {
		return {

		}
	},
	computed:{
		$t(){
			return function(key){
				const translateList = this.$tm.vx.state().translate.translates
				let str=key;
				if(!translateList){
					return str
				}
				translateList.forEach(item => {
					if (key == item.key) {
						str=item.value
					}
				})
				return str
			}
		},
		userInfo(){
			const userInfo = this.$tm.vx.state().user.userInfo
			return userInfo
		},
		appConfig(){
			const config = this.$tm.vx.state().app.config
			return config
		},
		translates(){
			const translateList = this.$tm.vx.state().translate.translates
			return translateList
		},
		isBlack(){
			return this.$tm.vx.state().tmVuetify.black
		},
		avatar(){
			let userInfo = this.$store.state.user.userInfo
			if(userInfo.avatar){
				return userInfo.avatar+"?v="+userInfo.avatarVer
			}
			const config = this.$tm.vx.state().app.config
			if(config.avatar){
				return config.avatar
			}
		}
	},
	watch:{
		translates(val,old){
			this.setTabbar()
		}
	},
	onShow(){
		//this.setTabbar()
	},
	methods: {
		trans(key) {
			const translateList = this.$tm.vx.state().translate.translates
			let str=key
			if(!translateList){
				return str
			}
			translateList.forEach(item => {
				if (key == item.key) {
					str=item.value
				}
			})
			return str
		},
		setTabbar(){
			uni.setTabBarItem({
			  index: 0,
			  text: this.trans('消息'),
			})
			uni.setTabBarItem({
			  index: 1,
			  text: this.trans('通讯录'),
			})
			uni.setTabBarItem({
			  index: 2,
			  text: this.trans('发现'),
			})
			uni.setTabBarItem({
			  index: 3,
			  text: this.trans('我的'),
			})
		},
		navigateTo(url){
			uni.navigateTo({url:url})
		},
		navto(url){
			uni.navigateTo({url:url})
		},
		back(){
			uni.navigateBack()
		},
		toast(msg){
			uni.showToast({
				title:msg,
				icon:'none'
			})
		}
	}
}